/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JReportView.java
 *
 * Created on 06/07/2010, 13:39:19
 */
package systole.view.tabs;

import java.awt.CardLayout;
import org.jfree.chart.ChartPanel;
import systole.domain.analysis.results.averages.AverageByDecade;
import systole.exceptions.ExceptionDAO;
import systole.persistence.FacadeDB;
import systole.view.tabs.controllers.AnalysisController;
import systole.view.tabs.results.JPnlReport;

/**
 *
 * @author jmj
 */
public class JReportView extends javax.swing.JPanel {

    private AnalysisController controller;
    private JPnlReport pnlReport;
    private AverageByDecade averageByDecade;


    /** Creates new form JReportView 
     * @param controller 
     */
    public JReportView(AnalysisController controller) {
        initComponents();
        this.controller = controller;

        try {
            this.averageByDecade = FacadeDB.getInstance().getAveragesBroker().getAverageByPatient(this.controller.getAnalysis().getPatient());
        } catch (ExceptionDAO ex) {
            FacadeDB.getInstance().refreshSession();
            this.averageByDecade = null;
        }
        this.pnlReport = new JPnlReport(controller.getAnalysis());
        this.controller.getReportModel().addObserver(this.pnlReport);
        this.add(this.pnlReport,"Report");
        this.showEmpty();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPnlEmpty = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();

        setMinimumSize(new java.awt.Dimension(875, 470));
        setName("Form"); // NOI18N
        setPreferredSize(new java.awt.Dimension(600, 450));
        setLayout(new java.awt.CardLayout());

        jPnlEmpty.setName("jPnlEmpty"); // NOI18N
        jPnlEmpty.setLayout(new java.awt.BorderLayout());

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(systole.view.SystoleApp.class).getContext().getResourceMap(JReportView.class);
        jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N
        jPnlEmpty.add(jLabel1, java.awt.BorderLayout.CENTER);

        add(jPnlEmpty, "Empty");
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPnlEmpty;
    // End of variables declaration//GEN-END:variables

    public void showEmpty() {
        ((CardLayout) this.getLayout()).show(this, "Empty");
    }

    public void showReport() {
        ((CardLayout) this.getLayout()).show(this, "Report");
    }

    /**
     * @return the pnlReport
     */
    public JPnlReport getPnlReport() {
        return pnlReport;
    }
  

}
